const { removeElement2 } = require('./移除元素')
const moveZeroes1 = function (nums) {
  let slow = 0
  let fast = 0
  while (fast < nums.length) {
    if (nums[fast] !== 0) {
      fast++
      slow++
    } else {
      slow = fast
      while (nums[fast] === 0) {
        fast++
      }
      if (fast >= nums.length) break
      let temp = nums[slow]
      nums[slow] = nums[fast]
      nums[fast] = temp
      slow++
      fast = slow
    }
  }
}

const moveZeroes2 = function (nums) {
  let slow = 0
  let fast = 0
  while (fast < nums.length) {
    if (nums[fast] !== 0) {
      let temp = nums[slow]
      nums[slow] = nums[fast]
      nums[fast] = temp
      slow++
    }
    fast++
  }
}

const moveZeroes3 = function (nums) {
  let p = removeElement2(nums, 0)
  while (p < nums.length) {
    nums[p] = 0
    p++
  }
}

const nums = [0]
moveZeroes3(nums)
